{extends file='layout/front.html'}

{block name='main'}
<script type="text/javascript" charset="utf-8">
$('.menu6').attr('class', 'menu6_cur');
</script>
<div class="main_t3"> </div>
<div class="main_c">
  {if $smarty.session.user.id == 1}
	<div class="main_top_btn_box pb15"><a href="#" class="modify_notice">修改平台公告</a></div>
	{/if}
	<div class="msg_box mt20">
		<div class="msg_box_t"></div>
		<div class="msg_box_c">
			<h3 class="msg_box_title">{date('Y-m-d', $notice.update_time)}</h3>
			<div class="p10 t2 lh24">{$notice.value}</div>
		</div>
		<div class="msg_box_b"></div>
	</div>
</div>
<script type="text/javascript" charset="utf-8">
  $('.modify_notice').click(function(){
    notice($('.msg_box_c div').html());

    return false;
  });
  
function notice(msg){

    $('#pop_notice').remove();
	var html = $('<div id="pop_notice">\
	<div class="popup_bg"></div>\
	<iframe class="popup_cover"></iframe>\
	<div class="popup_box center_fix">\
		<div class="popup_box_t"></div>\
		<div class="popup_box_c">\
			<h3 class="popup_box_title n">平台公告</h3>\
			<div class="pl20 pr20"><textarea class="textarea">'+msg+'</textarea></div>\
			<div class="popup_box_btn n"><a href="#" class="btn4">发布</a><a href="#" class="btn2">取消</a></div>\
		</div>\
		<div class="popup_box_b"></div>\
	</div></div>');

	$('.btn4', html).click(function(){
	  msg = $('.textarea', html).val();
	  if (!msg) {
	    show_msg('请填写内容', function(){
	      $('.textarea', html).focus();
	    });
	    return false;
	  }
	  $.post(SITE_URL+'/ajax/notice.html', { content:msg}, function(data){
	    html.remove();
	    if (data == '0') {
	      show_msg('请重新登录', function(){
	        location.href = SITE_URL+'/login.html';
	      });
	    }
	    location.reload();
	  });
		// do save
		return false;
	});

    $('.btn2', html).click(function(){
		html.remove();

		return false;
	});

	$('body').append(html);
	$(window).resize();
}
</script>
{/block}
